#coding:utf-8
import urllib
import re

inputfile = file('input.txt','r')

while True:
    line=inputfile.readline()
    if len(line)==0:
        break
    temp=line.rsplit(',')
    
    title = temp[0]
    negativekeyword=unicode(temp[1], 'utf-8')
    #print isinstance(negativekeyword, unicode)
    positivekeyword=unicode(temp[2], 'utf-8')
    print title
    
    url = 'http://www.geekpark.net/tools/search/content/'
    fullurl = url+title
    
    urlItem = urllib.urlopen(fullurl)
    result = urlItem.read().decode('utf-8')
    #result = urlItem.read()
    
    temp = re.findall(u'(?<=共有)\\d*(?=条记录)',result)
    itemcount = temp[0]
    print u'总记录数为:'+itemcount
    
    pagecount = int(itemcount)/10
    for i in range(1,pagecount):
        tempurl = fullurl+r'/'+str(i*10)
        urlItem = urllib.urlopen(tempurl)
        result += urlItem.read().decode('utf-8')
        #print len(result)
    
    urlItem.close()
    
    negativelist = re.findall(negativekeyword ,result)
    negativecount = len(negativelist)
    print negativekeyword,"的人共有:",negativecount
    
    positivelist = re.findall(positivekeyword,result)
    positivecount = len(positivelist)
    print positivekeyword,"的人共有:",positivecount
